package com.Polymorphic.One;

public class AnimalDemo1 {
    public static void main(String[] args) {
        Animal1 a = new Cat1();
        a.setName("加菲猫");
        a.setAge(5);
        System.out.println(a.getName()+","+a.getAge());
        a.eat();

        a = new Cat1("加菲猫",5);
        System.out.println(a.getName()+","+a.getAge());
        a.eat();

        System.out.println("-------------------------");

        Animal1 b = new Dog1();
        b.setName("海盗狗");
        b.setAge(4);
        System.out.println(b.getName()+","+b.getAge());
        b.eat();

        b =new Dog1("海盗狗",4);
        System.out.println(b.getName()+","+b.getAge());
        b.eat();
//        Cat1 c = (Cat1)a;
//        Dog1 d = (Dog1)b;
//        c.eat();
//        d.eat();

    }
}
